package com.gxa.insurance.controller;

import com.gxa.insurance.service.NewCarOrderService;
import com.gxa.insurance.util.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author wang li sha
 * @date 2022-06-06 17:58
 * <p>
 * 点击保存：
 * 1.根据订单编号查询订单Order对象order
 * 2.获取前端传入的map中的订单的各个字段，并修改order的字段
 * 3.定义update方法，传入参数order。根据order.id修改order表中记录的各字段
 */
@Api(value = "新车上牌订单相关的api接口")
@RestController
@RequestMapping("/newCarOrder")
@CrossOrigin
public class NewCarOrderController {
    @Autowired
    NewCarOrderService newCarOrderService;

    @ApiOperation("修改新车上牌信息的方法")
    @PostMapping("/update")
    @ApiImplicitParam(name = "(以json方式传入各个参数", value = "传值示例，请保持字段名相同 " +
            "{\n" +
            "  \"orderNumber\": \"666e1cdc4bf04b9ba443a4937904c106\",\n" +
            "  \"workCompany\": \"成都大众修理公司\",\n" +
            "  \"orderStatus\": \"已支付\",\n" +
            "  \"carId\": \"川A4300\",\n" +
            "  \"s4Area\": \"高新区\",\n" +
            "  \"driver\": \"老李\",\n" +
            "  \"isMakeCompemsation\": \"1\",\n" +
            "  \"isSendMessage\": \"1\",\n" +
            "  \"attention\": \"装窗贴，装坐垫\",\n" +
            "  \"userMessageContent\": \"用户你好，收到短信\",\n" +
            "  \"driverMessageContent\": \"司机你好，收到短信\",\n" +
            "  \"contactPerson\": \"张大大\",\n" +
            "  \"contactPhone\": \"13208191721\",\n" +
            "  \"inspectPlaceMap\": \"136,137\",\n" +
            "  \"inspectPlace\": \"北京晨德宝汽车销售有限公司\",\n" +
            "  \"tip\": \"申请免费洗车\"\n" +
            "}" +
            "\n" +
            "{\n" +
            "\"orderNumber\": \"2\",\n" +
            "\"workCompany\": \"四川宝马修理公司\",\n" +
            "\"orderStatus\": \"未支付\",\n" +
            "\"carId\": \"川A4300\",\n" +
            "\"s4Area\": \"武侯区\",\n" +
            "\"driver\": \"罗翔\",\n" +
            "\"isMakeCompemsation\": \"1\",\n" +
            "\"isSendMessage\": \"1\",\n" +
            "\"attention\": \"装窗贴，装坐垫\",\n" +
            "\"userMessageContent\": \"用户你好，收到短信\",\n" +
            "\"driverMessageContent\": \"司机你好，收到短信\",\n" +
            "\"contactPerson\": \"李四喜\",\n" +
            "\"contactPhone\": \"13208191721\",\n" +
            "\"inspectPlaceMap\": \"136,137\",\n" +
            "\"inspectPlace\": \"成都市北奔汽车修理厂销售有限公司\",\n" +
            "\"tip\": \"申请免费贴膜\"\n" +
            "}")
    public Map update(@RequestBody Map<String, String> maps) throws Exception {
        Integer update = newCarOrderService.update(maps);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(update);
        return jsonResult.getMap();
    }


}
